﻿
using System;
using System.Text;

namespace HttpClient
{
	public static class DoPut
	{
		public class DoPutUrl
		{
			HttpRequest request = new HttpRequest();
			public HeaderConfiguration<DoPutUrl> Using {get; private set;}
			public ContentConfiguration<DoPutUrl> InContent { get; private set; }
			
			public DoPutUrl(String url)
			{
				request.url = url;
				request.method = HttpMethod.PUT;
				Using = new HeaderConfiguration<DoPutUrl>(request, this);
				InContent = new ContentConfiguration<DoPutUrl>(request, this, Using);
			}
			
			public DoPutUrl WithXmlContent(String content)
			{
				Using.ContentType("application/xml");
				request.content = Encoding.UTF8.GetBytes(content);
				return this;
			}
			
			public HttpResponse ThenCall(HTTPClient client)
			{
				return client.Execute(request);
			}
		}
		
		public static DoPutUrl On(String url)
		{
			return new DoPutUrl(url);
		}
	}
}
